package cn.iocoder.yudao.module.book.dal.mysql.inventory;

import java.util.*;

import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.yudao.module.book.dal.dataobject.inventory.InventoryDO;
import org.apache.ibatis.annotations.Mapper;
import cn.iocoder.yudao.module.book.controller.admin.inventory.vo.*;

/**
 * 库存 Mapper
 *
 *
 */
@Mapper
public interface InventoryMapper extends BaseMapperX<InventoryDO> {

    default PageResult<InventoryDO> selectPage(InventoryPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<InventoryDO>()
                .eqIfPresent(InventoryDO::getBookId, reqVO.getBookId())
                .eqIfPresent(InventoryDO::getTotalCopies, reqVO.getTotalCopies())
                .eqIfPresent(InventoryDO::getAvailableCopies, reqVO.getAvailableCopies())
                .eqIfPresent(InventoryDO::getThreshold, reqVO.getThreshold())
                .betweenIfPresent(InventoryDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(InventoryDO::getId));
    }

}